package com.shsxt.crm.controller.servermanager;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shsxt.common.util.Result;
import com.shsxt.crm.model.YgCustomerServe;
import com.shsxt.crm.model.YgDataDic;
import com.shsxt.crm.service.IServerManageService;
import com.shsxt.framework.context.BaseController;

/**
 * 服务管理
 * 
 * @author Mr.YongGan.Zhang
 */
@Controller
@RequestMapping("/server")
public class ServerManageController extends BaseController {

	@Autowired
	private IServerManageService serverManage;

	@GetMapping("/{page}/index.shtml")
	public String index(@PathVariable("page") Integer page) {

		switch (page) {
		case 1:
			return "customer_serve_create"; // 服务创建
		case 2:
			return "customer_serve_assign"; // 服务分配
		case 3:
			return "customer_serve_proceed"; // 服务处理
		case 4:
			return "customer_serve_feed_back"; // 服务反馈
		case 5:
			return "customer_serve_archive"; // 服务归档
		default:
			return "500";
		}
	}

	/**
	 * 服务类别查询
	 * 
	 * @param dataDicName
	 * @return
	 */
	@PostMapping("/queryDataDicValueByDataDicName")
	@ResponseBody
	public List<YgDataDic> queryDataDicValueByDataDicName(String dataDicName) {
		return serverManage.queryDataDicValueByDataDicName(dataDicName);
	}

	@PostMapping("/insert")
	@ResponseBody
	public Result insertCustomerServerCreate(YgCustomerServe ygCustomerServe) {
		return serverManage.insertCustomerServerCreate(ygCustomerServe);
	}

	/**
	 *  查询客户服务
	 * @param state
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@PostMapping("/queryCustomerServesByParams")
	@ResponseBody
	public Map<String, Object> queryCustomerServesByParams(Integer state,
			@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize) {

		return serverManage.queryCustomerServesByParams(state, pageNum, pageSize);
	}

	@PostMapping("/update")
	@ResponseBody
	public Result updateCustomerServes(YgCustomerServe ygCustomerServe) {
		return serverManage.updateCustomerServes(ygCustomerServe);
	}

}
